﻿using System;
using RuanRang.Media.Core.Internal;
using RuanRang.Media.Core.Internal.Interop;
using RuanRang.Media.Core.Io;

namespace RuanRang.Media.Core.Media
{
    /// <summary>
    /// Empty media class
    /// </summary>
    public sealed class EmptyMedia : BaseMedia
    {
        /// <summary>
        /// Constructor of EmptyMedia
        /// </summary>
        /// <param name="mediaInput">The media input.</param>
        public EmptyMedia(MediaInput mediaInput)
            : base(mediaInput)
        {
            Name = mediaInput.Source;
        }

        /// <summary>
        /// Retreive the specified name of the media
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Gets the new media instance.
        /// </summary>
        /// <returns></returns>
        protected override IntPtr GetNewMediaInstance()
        {
            if (!string.IsNullOrEmpty(Name) && IntropHandleManager.LibVlcHandle != IntPtr.Zero)
            {
                return LibVlcMediaInterop.libvlc_media_new_as_node(IntropHandleManager.LibVlcHandle, Name);
            }
            return IntPtr.Zero;
        }
    }
}